import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:"/",
    redirect:"/login"
  },
  {
    path:"/login",
    name:"login",
    component:() => import("@/views/Login.vue")
  },
  {
    path:"/main",
    name:"main",
    component:() => import("@/views/Main.vue"),
    redirect:"/user/user",
    children:[
      {
        path:"/user/user",
        name:"user",
        component:() => import("@/views/user/user/User.vue")
      },
      {
        path:"/user/role",
        name:"role",
        component:() => import("@/views/user/role/Role.vue")
      },
      {
        path:"/user/auth",
        name:"auth",
        component:() => import("@/views/user/auth/Auth.vue")
      },
      {
        path:"/goods/category",
        name:"category",
        component:() => import("@/views/goods/category/Category.vue")
      },
      {
        path:"/goods/goods",
        name:"goods",
        component:() => import("@/views/goods/goods/Goods.vue")
      },
    ]
  },
  

]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router
